package com.dailyblue.project.estate.parking.controller;

import com.dailyblue.project.estate.commons.bean.Parking;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.parking.service.ParkingService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/parking")
public class ParkingController {
    @Resource
    private ParkingService parkingService;

    @PostMapping
    public JsonResult save(Parking parking) {
        return parkingService.addParking(parking);
    }

    @GetMapping("/findOne/{id}")
    JsonResult findOneParking(@PathVariable("id") String parkingId){
        return parkingService.findOneParking(parkingId);
    }

    @GetMapping
    public JsonResult findAllParkings(){
        return parkingService.findAllParkings();
    }

    @DeleteMapping("/delete/{id}")
    public JsonResult deleteParking(@PathVariable("id") String parkingId){
        return parkingService.deleteParking(parkingId);
    }

    @PutMapping("/update")
    public JsonResult updateParking(@RequestBody Parking parking){
        return parkingService.updateParking(parking);
    }
}
